import { defHttp } from '@/utils/http/axios';
import { CategorytAddData, CategorytEditData, CategorytListResult } from './types';

enum Api {
  productCategoryListApi = '/mall/op/product-category/tree',
  productCategoryAddApi = '/mall/op/product-category/add',
  productCategoryEditApi = '/mall/op/product-category/edit',
  productCategoryDelApi = '/mall/op/product-category/del',
  productCategorySwapApi = '/mall/op/product-category/swap',

  brandIndustryListApi = '/mall/op/brand-industry/tree',
  brandIndustryAddApi = '/mall/op/brand-industry/add',
  brandIndustryEditApi = '/mall/op/brand-industry/edit',
  brandIndustryDelApi = '/mall/op/brand-industry/del',
  brandIndustrySwapApi = '/mall/op/brand-industry/swap',
}

/**
 * @description 产品类目列表
 * @date
 * @export
 * @param
 */
export function productCategoryList(params: any) {
  return defHttp.get<CategorytListResult[]>({
    url: Api.productCategoryListApi,
    params
  });
}

/**
 * @description 新建产品类目
 * @date 26/01/2024
 * @export
 * @param {CategorytAddData} data
 */
export function productCategoryAdd(data: CategorytAddData) {
  return defHttp.post({ url: Api.productCategoryAddApi, data });
}

/**
 * @description 编辑产品类目
 * @date 26/01/2024
 * @export
 * @param {ProducCategorytEditData} data
 */
export function productCategoryEdit(data: CategorytEditData) {
  return defHttp.post({ url: Api.productCategoryEditApi, data });
}

/**
 * @description 删除产品类目
 * @date 26/01/2024
 * @export
 * @param {number} id
 */
export function productCategoryDel(id: number) {
  return defHttp.post({ url: Api.productCategoryDelApi + `/${id}` });
}

/**
 * @description 产品类目切换排序
 * @date 26/01/2024
 * @export
 * @param {number[]} data
 */
export function productCategorySwap(data: number[]) {
  return defHttp.post({ url: Api.productCategorySwapApi, data });
}


/**
 * @description 品牌门店经营类目列表
 * @date
 * @export
 * @param
 */
export function brandIndustryList(params: any) {
  return defHttp.get<CategorytListResult[]>({
    url: Api.brandIndustryListApi,
    params
  });
}

/**
 * @description 新建品牌门店经营类目
 * @date 26/01/2024
 * @export
 * @param {CategorytAddData} data
 */
export function brandIndustryAdd(data: CategorytAddData) {
  return defHttp.post({ url: Api.brandIndustryAddApi, data });
}

/**
 * @description 编辑品牌门店经营类目
 * @date 26/01/2024
 * @export
 * @param {CategorytEditData} data
 */
export function brandIndustryEdit(data: CategorytEditData) {
  return defHttp.post({ url: Api.brandIndustryEditApi, data });
}

/**
 * @description 删除品牌门店经营类目
 * @date 26/01/2024
 * @export
 * @param {number} id
 */
export function brandIndustryDel(id: number) {
  return defHttp.post({ url: Api.brandIndustryDelApi + `/${id}` });
}

/**
 * @description 品牌门店经营类目切换排序
 * @date 26/01/2024
 * @export
 * @param {number[]} data
 */
export function brandIndustrySwap(data: number[]) {
  return defHttp.post({ url: Api.brandIndustrySwapApi, data });
}